package com.oreilly.ez.fileserver.web;

import com.oreilly.ez.fileserver.base.R;
import com.oreilly.ez.fileserver.entity.NoteCate;
import com.oreilly.ez.fileserver.entity.NoteCate;
import com.oreilly.ez.fileserver.service.INoteCateService;
import com.oreilly.ez.fileserver.service.INoteCateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api
@CrossOrigin
@RestController
@RequestMapping("/noteCates")
public class NoteCateCtrl extends BaseCtrl<NoteCate> {

    @Autowired
    private INoteCateService noteCateService;

    @Override
    Object find(NoteCate item, @PageableDefault Pageable pageable) throws Exception {
        Page<NoteCate> page = noteCateService.find(item, pageable);
        return R.ok(page);
    }

    @Override
    Object findById(@PathVariable String id) throws Exception {
        NoteCate item = noteCateService.findById(id);
        return R.ok(item);
    }

    @Override
    Object add(@RequestBody  NoteCate item) throws Exception {
         noteCateService.add(item);
         return R.ok(item);
    }

    @Override
    Object update(@RequestBody NoteCate item) throws Exception {
        noteCateService.update(item);
        return R.ok(item);
    }

    @Override
    Object delete(String[] ids) throws Exception {
        noteCateService.deleteByIds(ids);
        return R.ok("delete ok");
    }
}
